/*
 * Created by JFormDesigner on Fri Apr 15 23:29:15 CST 2022
 */

package com.ZengQi.event.view;

import com.ZengQi.event.controller.PublisherController;
import com.ZengQi.event.entity.Publisher;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout;

/**
 * @author QI Zeng
 */
public class PublisherMainView extends JFrame {
    private String thisPublisher;
    private PublisherController publisherController=new PublisherController();
    public PublisherMainView(Publisher publisher) {
thisPublisher=publisher.getPublisherName();
        initComponents();
        textField1.setText(publisher.getPublisherName());
        setVisible(true);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
//加题按钮事件监听
    private void addTopicBtn(ActionEvent e) {
        new AddTopicView(thisPublisher);
    }

    private void logoutBtn(ActionEvent e) {
        new VisitorsMainView();
        dispose();
    }

    /**
     * 界面布局及初始化
     */
    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        label1 = new JLabel();
        textField1 = new JTextField();
        addTopicBtn = new JButton();
        logoutBtn = new JButton();

        //======== this ========
        setTitle("\u505a\u9898\u5e2e");
        setIconImage(new ImageIcon(getClass().getResource("/bang.png")).getImage());
        Container contentPane = getContentPane();

        //---- label1 ----
        label1.setText("\u6b22\u8fce\u60a8\u4f01\u4e1a\u4eba\u5458");

        //---- addTopicBtn ----
        addTopicBtn.setText("\u51fa\u9898");
        addTopicBtn.addActionListener(e -> addTopicBtn(e));

        //---- logoutBtn ----
        logoutBtn.setText("\u9000\u51fa\u767b\u5f55");
        logoutBtn.addActionListener(e -> logoutBtn(e));

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(106, 106, 106)
                            .addComponent(label1, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(textField1, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE)
                            .addGap(85, 85, 85)
                            .addComponent(logoutBtn, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE))
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(242, 242, 242)
                            .addComponent(addTopicBtn, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(88, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label1, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(logoutBtn))
                    .addGap(116, 116, 116)
                    .addComponent(addTopicBtn, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(182, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JLabel label1;
    private JTextField textField1;
    private JButton addTopicBtn;
    private JButton logoutBtn;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
